package com.zhou.controller;

import com.zhou.result.R;
import com.zhou.service.FriendService;
import com.zhou.utils.APPApplicationException;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description : 好友关系
 * @Author : zyy
 * @Date: 2024/6/25  11:40
 */
@RestController
@RequestMapping("/friend")
@Slf4j
@Api(tags = "好友关系")
public class FriendController {

    @Resource
    private FriendService friendService;

    @Operation(summary = "新增好友")
    @PostMapping("add")
    private R add(String uid, String fid) {
        try {
            return R.success(friendService.add(uid,fid));
        }catch (APPApplicationException e) {
            return R.error(e.getMessage());
        }
    }

    @Operation(summary = "同意好友")
    @PutMapping("update/is_agree")
    private R updateAgree(String uid, String fid,Integer isAgree) {
        try {
            return R.success(friendService.updateAgree(uid,fid,isAgree));
        }catch (APPApplicationException e) {
            return R.error(e.getMessage());
        }
    }

    @Operation(summary = "删除好友")
    @DeleteMapping("delete")
    private R deleteById(String uid, String fid) {
        try {
            return R.success(friendService.deleteById(uid,fid));
        }catch (APPApplicationException e) {
            return R.error(e.getMessage());
        }
    }

    @Operation(summary = "拉黑好友")
    @PutMapping("update/black_like")
    private R updateBlock(String uid, String fid,Integer blackLike) {
        try {
            return R.success(friendService.updateBlock(uid,fid,blackLike));
        }catch (APPApplicationException e) {
            return R.error(e.getMessage());
        }
    }
}
